Skip to content

"Enabled hardening configs default to build. (#1223)"" - #2232

Open
Jaihind Yadav (jaihindy) wants to merge 1 commit into
qualcomm-linux:masterfrom
jaihindy:revert-1904-revert
Open

"Enabled hardening configs default to build. (#1223)""#2232
Jaihind Yadav (jaihindy) wants to merge 1 commit into
qualcomm-linux:masterfrom
jaihindy:revert-1904-revert

Conversation

@jaihindy

@jaihindy Jaihind Yadav (jaihindy) commented May 19, 2026

Copy link
Copy Markdown
Contributor

Include hardening.config in kernel configuration

Include hardening.config via merge_config.sh during kernel
configuration to enable consistent security hardening across
all builds.

Previously, kernel configurations did not include these
defaults, resulting in missing compiler-based mitigations and
other hardening features.

Set CONFIG_KSTACK_ERASE to 'n' as enabling it embeds absolute
build paths into out-of-tree kernel modules, leading to
Yocto QA buildpath failures.

This ensures hardened defaults while maintaining clean QA
compliance.

Keep CONFIG_INIT_ON_ALLOC_DEFAULT_ON and
CONFIG_INIT_ON_FREE_DEFAULT_ON disabled due to a TrustZone issue on
RB4 that causes boot failures when memory initialization hardening
is enabled. The TrustZone team is working on a fix. Re-enable these
options once the issue is resolved.

Update:
A fix for the CONFIG_KSTACK_ERASE build path issue has been submitted upstream - https://lore.kernel.org/all/20260820060116.786173-1-jaihindy@qti.qualcomm.com/ to the Linux kernel mailing list (upstream patch submission). The upstream maintainer has indicated that the change is expected to be merged in a future kernel release. Once the upstream fix is available and integrated, we plan to enable CONFIG_KSTACK_ERASE=y as part of the default hardening configuration.

@vkraleti

Copy link
Copy Markdown
Contributor

Avoid “Revert of revert” in the commit message. This doesn't provide any meaningful info on the change. Instead, restore the original commit message to provide sufficient context on why this change is being made.

@github-actions

Copy link
Copy Markdown

Test run workflow

Test jobs for commit 53697a4

qcom-distro
Pass: 6 | Fail: 3 | Total: 9
nodistro
Pass: 6 | Fail: 3 | Total: 9
qcom-distro_linux-qcom-6.18
Pass: 5 | Fail: 2 | Total: 7

@test-reporting-app

test-reporting-app Bot commented May 19, 2026

Copy link
Copy Markdown

Test Results

 30 files   30 suites   2h 6m 45s ⏱️
 13 tests  10 ✅ 0 💤 3 ❌
266 runs  260 ✅ 0 💤 6 ❌

For more details on these failures, see this check.

Results for commit 572eea6.

♻️ This comment has been updated with latest results.

@quaresmajose

Copy link
Copy Markdown
Contributor

Avoid “Revert of revert” in the commit message. This doesn't provide any meaningful info on the change. Instead, restore the original commit message to provide sufficient context on why this change is being made.

"Reapply" is another option for “Revert of revert” and recent verions of git uses this formulation.

@lumag

Copy link
Copy Markdown
Contributor

Missing SoB. Why?

@ricardosalveti

Copy link
Copy Markdown
Contributor

No commit message, failing DCO, please follow the guidelines for commit messages from this repository.

@lumag Dmitry Baryshkov (lumag) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please respond to review comments.

@jaihindy Jaihind Yadav (jaihindy) changed the title Revert "Revert "Enabled hardening configs default to build. (#1223)"" "Enabled hardening configs default to build. (#1223)"" May 25, 2026
@rsiddoji

Copy link
Copy Markdown
Contributor

Please respond to review comments.
On enabling hardening we started seeing bootup failure , Where the fix is in Non-HLOS builds . We are waiting for Non-HLOS images to be release to public repo , which were causing bootup failure ETA from the team is Jun 5 and we can proceed post these are consumed by the meta-qcom.

@ricardosalveti

Copy link
Copy Markdown
Contributor

Nothing changed here, not even DCO is passing.

@rsiddoji

Copy link
Copy Markdown
Contributor

Nothing changed here, not even DCO is passing.

Yes, that’s correct. The non-HLOS binaries need to be published and then consumed by meta-qcom (outside of the PR activity). Only after this is completed PR will pass so waiting for the binaries. We will work on the comments once this non-hlos binaries are updated.

JFI :
Due to enablement of hardening -we started seeing early bootup crash on the device (like 8300 ),
RCA : Memory craved out was not inline to expectation and kernel was initialization the memory (due to enablement of hardening- uncovered issue) and was crashing. As the Hardening enablement is been Reverted this PR want to bring it back.
Fix: Correction/fix is part of tz.mbn so nee pre-build should be published and consumed by meta-qcom build.
Action: we will start working on this PR once we have this tz.mbn updated and consumed by meta-qcom builds.

@ricardosalveti

Copy link
Copy Markdown
Contributor

Moving to draft then.

@ricardosalveti
Ricardo Salveti (ricardosalveti) marked this pull request as draft June 1, 2026 10:42
@jaihindy
Jaihind Yadav (jaihindy) marked this pull request as ready for review July 1, 2026 08:04
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

Test run workflow

Test jobs for commit 56e7abd

nodistro
Pass: 9 | Fail: 1 | Total: 10
qcom-distro_linux-qcom-6.18
Pass: 7 | Fail: 1 | Total: 8
qcom-distro
Pass: 9 | Fail: 1 | Total: 10

@bhargav0610

Copy link
Copy Markdown

bootup issue on rb4 on all distros
https://lava.infra.foundries.io/scheduler/job/304222

@github-actions

Copy link
Copy Markdown

Test run workflow

Test jobs for commit faa6a59

nodistro
Pass: 10 | Fail: 0 | Total: 10
qcom-distro_linux-qcom-6.18
Pass: 224 | Fail: 0 | Total: 244
qcom-distro
Pass: 9 | Fail: 1 | Total: 10

@lumag Dmitry Baryshkov (lumag) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not to mention that commit doesn't follow established guidelines. See CONTRIBUTING.md

CONFIG_VETH=m
# Disable stack erase plugin to avoid buildpath leakage in out-of-tree modules
CONFIG_KSTACK_ERASE=n
# Disabled due to TrustZone memory allocator initialization failure

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? This would usually point out the error in the memory map. Can the boards boot with CONFIG_MEMTEST=y and memtest=1 kernel arg?

@jaihindy Jaihind Yadav (jaihindy) Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We performed additional debugging and identified that the failure is occurring during TrustZone SHM Bridge enablement. Specifically, the following API returns a non-zero status from TrustZone:
ret = qcom_scm_shm_bridge_enable(qcom_tzmem_dev);
Show more lines

Debug logs show:

[ 0.070390] qcom_scm firmware:scm: SHM bridge enable raw result: ret=0 res0=97 res1=0 res2=0
[ 0.070391] qcom_scm firmware:scm: SHM bridge enable returned non-zero status: 97

From the collected logs:

The SHM Bridge feature availability check succeeds (avail=1).

The SCM call itself completes successfully (ret=0).

However, TrustZone returns status 97 in res0.

The kernel interprets this status as a failure and reports:

Failed to enable the TrustZone memory allocator

Additionally, I tested:
CONFIG_QCOM_TZMEM_MODE_GENERIC=y
instead of:
CONFIG_QCOM_TZMEM_MODE_SHMBRIDGE=y
With GENERIC mode, the device boots successfully, including when the kernel hardening configurations (CONFIG_INIT_ON_ALLOC_DEFAULT_ON and CONFIG_INIT_ON_FREE_DEFAULT_ON) are enabled.

We have engaged the TrustZone (SSG) team and shared the debug findings. They are currently investigating why TrustZone returns status 97 for the SHM Bridge enable request on this platform.

Even if a TrustZone-side fix is identified, it is expected to take considerable time before it becomes available in the Non-HLOS images used by the nightly builds. Since this issue was only recently uncovered, waiting for the firmware fix would significantly delay the rollout of the hardening configuration changes.

Therefore, I would kindly request approval of this change while we continue to work with the SSG team on the root-cause analysis and firmware-side resolution of the SHM Bridge enablement failure. Once the fix will be available we'll enable CONFIG_INIT_ON_ALLOC_DEFAULT_ON and CONFIG_INIT_ON_FREE_DEFAULT_ON back.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to wait until we are able to identify a fix from the TrustZone-side, as we do want to find these type of issues.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any progress on this issue?

@github-actions

Copy link
Copy Markdown

Test run workflow

Test jobs for commit faa6a59

nodistro
Pass: 10 | Fail: 0 | Total: 10
qcom-distro_linux-qcom-6.18
Pass: 239 | Fail: 0 | Total: 259
qcom-distro
Pass: 267 | Fail: 2 | Total: 295

@jaihindy

Copy link
Copy Markdown
Contributor Author

Not to mention that commit doesn't follow established guidelines. See CONTRIBUTING.md

Thanks . I"ll fix the commit message accordingly.

@github-actions

Copy link
Copy Markdown

Test run workflow

Test jobs for commit c1122bc

nodistro
Pass: 10 | Fail: 0 | Total: 10
qcom-distro_linux-qcom-6.18
Pass: 220 | Fail: 0 | Total: 245
qcom-distro
Pass: 276 | Fail: 2 | Total: 297

@koenkooi

Copy link
Copy Markdown
Contributor

Not to mention that commit doesn't follow established guidelines. See CONTRIBUTING.md

Thanks . I"ll fix the commit message accordingly.

Latest push still has a non-compliant commit message. See CONTRIBUTING.md and for our robot helpers, have the tool follow https://github.com/qualcomm-linux/meta-qcom/blob/master/AGENTS.md

@koenkooi Koen Kooi (koenkooi) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commit message

@jaihindy

Copy link
Copy Markdown
Contributor Author

Commit message
Thanks for review.
I reviewed the contribution guidelines and checked the recent git history. For similar changes, I noticed that updates were split into separate commits per kernel branch. Could you please confirm if the same approach is expected for this PR?
For example:

  1. linux-qcom-next: enable hardening with CONFIG_KSTACK_ERASE override
  2. linux-qcom-6.18: enable hardening with CONFIG_KSTACK_ERASE override
  3. linux-qcom-next: disable INIT_ON_ALLOC/INIT_ON_FREE due to TZMEM boot issue.
  4. linux-qcom-6.18: disable INIT_ON_ALLOC/INIT_ON_FREE due to TZMEM boot issue.
    I want to ensure the changes are structured according to the project's contribution requirements before updating the PR.

@koenkooi

Copy link
Copy Markdown
Contributor

That's a much better commit message!

@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown

Test run workflow

Test jobs for commit 572eea6

qcom-distro
Pass: 11 | Fail: 1 | Total: 12
nodistro
Pass: 10 | Fail: 0 | Total: 10
qcom-distro_linux-qcom-6.18
Pass: 7 | Fail: 1 | Total: 8

@qcomlnxci

Copy link
Copy Markdown

Test Coral run workflow

Test jobs for commit 648a747

  • qcomdistro: multimedia image
    Pass: 9 | Fail: 0 | Total: 9
  • qcomdistro: multimedia image-prop
    Pass: 42 | Fail: 2 | Total: 44

@lumag Dmitry Baryshkov (lumag) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be fixed in the kernel tree rather than requiring a fix for every module.

@ricardosalveti

Copy link
Copy Markdown
Contributor

Conflicts will have to be fixed as well.

@jaihindy
Jaihind Yadav (jaihindy) force-pushed the revert-1904-revert branch 2 times, most recently from 060f012 to 2233e29 Compare July 19, 2026 10:24
against this kernel inherit the same behavior without per-module
workarounds.

Upstream-Status: Pending

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No Pending patches, thanks.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi ,
We are actively working with the upstream kernel community to address this issue. Based on the latest feedback from the upstream maintainer, the proposed fix appears to be on the right track, and Nathan indicated that he is willing to take the patch through the upstream process.
I've attached a screenshot of the upstream feedback for reference.

image

Given this, can we proceed with CONFIG_KSTACK_ERASE=n for now and then switch to CONFIG_KSTACK_ERASE=y once the upstream patch is merged into a future kernel version?

For reference, the latest upstream submission is available here:

PATCH v3 - suppress recorded GCC switches for extmod builds
https://lore.kernel.org/all/20260820060116.786173-1-jaihindy@qti.qualcomm.com/

Please let me know your thoughts.

Thanks,
Jaihind

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please let me know your thoughts

Please check the files under Documentation/process, they might make your upstream submission smoother.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for suggestion. I'll review the documents in Documentation/process and incorporate the guidance to improve future upstream submissions.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given this, can we proceed with CONFIG_KSTACK_ERASE=n for now and then switch to CONFIG_KSTACK_ERASE=y once the upstream patch is merged into a future kernel version?

No, wait for it to be accepted by the maintainers into their tree.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dmitry,
I believe we should proceed with Jaihind's proposal to set CONFIG_KSTACK_ERASE=n, as the upstream review is still in progress and waiting for the change to flow back into our tree could take additional time.

Further delaying the hardening effort may introduce more issues similar to those we have already encountered. As seen previously, this was not an isolated case, and we identified three separate issues that required considerable debugging effort and follow-up discussions.

It is also important to recognize that hardening is not limited to CONFIG_KSTACK_ERASE alone. The earlier we enable and validate these hardening features, the more time we will have to identify potential regressions, strengthen the implementation, and ensure a robust solution before the release.

Thanks.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we sort out the issue with one of the hardening options causing an error because of the incorrect boot memory map? If that is solved and the option is reenabled, I'm fine with mering this PR.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry Dmitry we were waiting for the Bootup crash related fix to be part of mainline below is the status .

Early bootup crash is fixed as part of firmware update "#3069" waiting for approval.

GCC KSTACK related is getting tracked as part of
https://git.kernel.org/pub/scm/linux/kernel/git/kbuild/linux.git/commit/?id=51794b107d54b3c9a8ebbe12a3b81d8495bd482c

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was the last commit backported to qcom-next and qcom-6.18?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We had not created any backport for qcom-next or qcom-6.18 yet , Waiting for backport will futher delay . As agreed earlier we should go for enabling the hardening first and later we will get this backports .
We are still waiting for #3069 closer .

Enable hardening.config in the default KERNEL_CONFIGS list to
provide a stronger security baseline across meta-qcom targets.

Keep CONFIG_KSTACK_ERASE disabled to avoid embedding build path
information into out-of-tree kernel modules, which triggers Yocto
buildpath QA failures.

Keep CONFIG_INIT_ON_ALLOC_DEFAULT_ON and
CONFIG_INIT_ON_FREE_DEFAULT_ON disabled due to a memmap issue in UEFI on
RB4 that causes boot failures when memory initialization hardening
is enabled. The UEFI team is in process of merging the change. Re-enable these
options once the fix is available in the meta.

Signed-off-by: Jaihind Yadav <jaihindy@qti.qualcomm.com>
@qcomlnxci

Copy link
Copy Markdown

Test Coral run workflow

Test jobs for commit 572eea6

  • qcomdistro: multimedia image
    Pass: 9 | Fail: 0 | Total: 9
  • qcomdistro: multimedia image-prop
    Pass: 40 | Fail: 4 | Total: 44

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants